package com.dzt.androidframework.activity;


import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.TextView;


import com.dzt.androidframework.R;

import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;


public class SplashActivity extends ActivityFrame {

	@ViewInject(R.id.tv_hint)
	private TextView tvHint;
	private int count = 2;

	private Handler handler = new Handler(new Handler.Callback() {
		@Override
		public boolean handleMessage(Message msg) {
			switch (msg.what) {
				case 0:
					startActivity(MainActivity.class, null);
					finish();
					break;
				case 1:
					if (count == -1) {
						startActivity(MainActivity.class, null);
						finish();
						break;
					}
					tvHint.setText(count + "跳过");
					handler.sendEmptyMessageDelayed(1, 1000);
					count--;
					break;
				default:
					break;
			}
			return false;
		}
	});

	@Override
	protected int getLayoutId() {
		return R.layout.activity_splash;
	}

	@Override
	protected void initParams() {
	}

	@Override
	protected void initData(Bundle savedInstanceState) {

	}

	@Override
	protected void onResume() {
		super.onResume();
		handler.sendEmptyMessageDelayed(1, 1000);
	}

	@Override
	protected String[] initPermissions() {
		return null;
	}

	@Event(value = {R.id.tv_hint})
	private void onViewClick(View v) {
		switch (v.getId()) {
			case R.id.tv_hint:
				handler.removeMessages(1);
				handler.sendEmptyMessage(0);
				break;
			default:
				break;
		}
	}
}
